package com.sangfor.provider.service;

import com.sangfor.provider.dao.DepartDao;
import com.sangfor.provider.entity.Depart;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 朱勇军
 * @date 2020/7/25
 */
@Service("departService")
public class DepartServiceImpl implements DepartService {

    @Resource
    private DepartDao departDao;

    @Override
    public Depart createDepart(Depart depart) {
        return departDao.save(depart);
    }

    @Override
    public Depart updateDepart(Depart depart) {
        return departDao.save(depart);
    }

    @Override
    public boolean removeDepartById(Integer id) {
        if (departDao.existsById(id)){
            departDao.deleteById(id);
            return true;
        }
        return false;
    }

    @Override
    public Depart getDepart(Integer id) {
        if (departDao.existsById(id)){
            return departDao.getOne(id);
        }
        return null;
    }

    @Override
    public List<Depart> listAllDepart() {
        return departDao.findAll();
    }
}
